import { Input } from "antd"
import { FC } from "react"

import { SFormItem } from "@/components/common"
import { useLocale } from "@/locales"
import { onlyPositiveNumber } from "@/utils/validate"

interface InsuranceIdInputProps {
	isHideLabel?: boolean
	onChange?: (text: string) => void
}

const InsuranceIdInput: FC<InsuranceIdInputProps> = ({ isHideLabel = false, onChange }) => {
	const { newFormat } = useLocale()

	const onNotAllow = (value: string) => {
		onChange && onChange(value)
	}

	return (
		<SFormItem name="insuranceId" label={isHideLabel ? "" : newFormat("dxn.game_list.insurance_bill_number")}>
			<Input placeholder={newFormat("common.please_enter")} allowClear onChange={e => onlyPositiveNumber(e, onNotAllow)} />
		</SFormItem>
	)
}

export default InsuranceIdInput
